<template>
  <!-- 库存组件 -->
  <div class="component-commonStock">
    <div class="component-mainHeader">
      <div class="top">
        <div class="topleft">
          <p>
            <span class="iconfont" style="color:#1abc9a;margin-right:3px;">&#xe607;</span>平衡总表
          </p>
        </div>
        <div class="topright">
          <el-button type="info" @click="$router.go(0)">
            <span style="font-weight:700;margin-right:5px;" class="iconfont">&#xe662;</span>刷新
          </el-button>
        </div>
      </div>
    </div>



    <div class="tabs">
      <el-tabs v-model="activeName" type="border-card" @tab-click="handleClick" class="tabs-header">
        <el-tab-pane label="材料" name="first">
          <div class="component-listHeader">
            <div class="search-header">
              <div class="left-title">
                <p class="left-text">
                  <span class="iconfont" style="margin-right:3px;">&#xe61e;</span>材料平衡总表
                </p>
              </div>
            </div>
          </div>
          <div>
            <el-table
              ref="multipleTable"
              :data="info"
              tooltip-effect="dark"
              style="width: 1100px;margin:0 auto;"
              border
            >
              <!--<el-table-column label="材料类别" align="center" prop=""></el-table-column>-->
              <el-table-column label="材料名称" align="center" prop="matName"></el-table-column>
              <el-table-column label="型号" align="center" prop="matModel"></el-table-column>
              <el-table-column label="单位" align="center" prop="matUnit"></el-table-column>
              <el-table-column label="入库量" align="center" prop="inNum"></el-table-column>
              <el-table-column label="出库量" align="center" prop="outNum"></el-table-column>
              <el-table-column label="施工实用量" align="center" prop="useNum"></el-table-column>
              <el-table-column label="结算用量" align="center" prop="numberThree"></el-table-column>
              <el-table-column label="项目部库存" align="center" prop="numberOne"></el-table-column>
              <el-table-column label="施工队总库存" align="center" prop="numberTwo"></el-table-column>
              <el-table-column label="对内总库存" align="center" prop="innerTotalNum"></el-table-column>
              <el-table-column label="对外总库存" align="center" prop="externalTotalNum"></el-table-column>
              <!--<el-table-column label="操作信息" align="center">
                <template slot-scope="scope">
                  <el-button
                    @click="$router.push({name:'balanceRecords',params:{info:scope.row}})"
                    type="text"
                    size="small"
                    class="iconfont icondelete red"
                  >查看记录</el-button>
                </template>
              </el-table-column>-->
            </el-table>
            <div class="component-paging" style="width: 100%;" v-if="info.length > 0">
              <div class="table-bottom" style="width: 100%;">
                <div class="bottom-left" style="margin-left: 42px;"></div>
                <div class="paging">
                  <div class="paging-left">
                    <p>
                      共
                      <span>{{Math.ceil(total/pageSize)}}</span> 页/
                      <span>{{total}}</span> 条数据
                    </p>
                  </div>
                  <el-pagination
                    background
                    @size-change="SizeChange($event,dataInit,currentPage,pageSize)"
                    @current-change="CurrentChange($event,dataInit,currentPage,pageSize)"
                    :current-page.sync="currentPage"
                    :page-sizes="[10, 20, 30]"
                    :page-size.sync="pageSize"
                    layout="sizes, prev, pager, next, jumper"
                    :total="total"
                  ></el-pagination>
                </div>
              </div>
            </div>
          </div>

        </el-tab-pane>
        <el-tab-pane label="设备" name="second">
          <div class="component-listHeader">
            <div class="search-header">
              <div class="left-title">
                <p class="left-text">
                  <span class="iconfont" style="margin-right:3px;">&#xe61e;</span>材料平衡总表
                </p>
              </div>
            </div>
          </div>
          <div>
            <el-table
              ref="multipleTable"
              :data="infos"
              tooltip-effect="dark"
              style="width: 1100px;margin:0 auto;"
              border
            >
              <!--<el-table-column label="材料类别" align="center" prop></el-table-column>-->
              <el-table-column label="材料名称" align="center" prop="matName"></el-table-column>
              <el-table-column label="型号" align="center" prop="matModel"></el-table-column>
              <el-table-column label="设备码" align="center" prop="matUnit"></el-table-column>
              <el-table-column label="单位" align="center" width="50" prop=""></el-table-column>
              <el-table-column label="入库量" align="center" width="70" prop="inNum"></el-table-column>
              <el-table-column label="出库量" align="center" width="70" prop="outNum"></el-table-column>
              <el-table-column label="施工实用量" align="center" width="70" prop="useNum"></el-table-column>
              <el-table-column label="结算用量" align="center" width="70" prop="numberThree"></el-table-column>
              <el-table-column label="项目部库存" align="center" prop="numberOne"></el-table-column>
              <el-table-column label="施工队总库存" align="center" prop="numberTwo"></el-table-column>
              <el-table-column label="对内总库存" align="center" prop="innerTotalNum"></el-table-column>
              <el-table-column label="对外总库存" align="center" prop="externalTotalNum"></el-table-column>
              <!--<el-table-column label="操作信息" align="center">
                <template slot-scope="scope">
                  <el-button
                    @click="$router.push({name:'balanceRecords',params:{info:scope.row}})"
                    type="text"
                    size="small"
                    class="iconfont icondelete red"
                  >查看记录</el-button>
                </template>
              </el-table-column>-->
            </el-table>
            <div class="component-paging" style="width: 100%" v-if="infos.length > 0">
              <div class="table-bottom" style="width: 100%">
                <div class="bottom-left" style="margin-left: 42px;"></div>
                <div class="paging">
                  <div class="paging-left">
                    <p>
                      共
                      <span>{{Math.ceil(totals/pageSize)}}</span> 页/
                      <span>{{totals}}</span> 条数据
                    </p>
                  </div>
                  <el-pagination
                    background
                    @size-change="SizeChange($event,dataInit,currentPages,pageSizes)"
                    @current-change="CurrentChange($event,dataInit,currentPages,pageSizes)"
                    :current-page.sync="currentPages"
                    :page-sizes="[10, 20, 30]"
                    :page-size.sync="pageSizes"
                    layout="sizes, prev, pager, next, jumper"
                    :total="totals"
                  ></el-pagination>
                </div>
              </div>
            </div>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>

  </div>
</template>

<script>
  export default {
    props: ["flag"],
    data() {
      return {
        activeName: "first",
        // 排序方式的v-model
        sortBy: "",
        value: "",
        info: [], //表格内容
        infos:[],
        total: 1, // 数据总条数
        pageSize: 10,// 每页显示数据的条数
        currentPage: 1,// 当前显示的页面页码
        totals:1,
        pageSizes:10,
        currentPages:1,
      };
    },
    mounted(){
      this.dataInit();
    },
    methods: {
      dataInit(){
        let suCb = res => {
          switch (this.activeName) {
            case "first":
              this.total = res.data.rowCount;
              this.info = res.data.data;
              break;
            case "second":
              this.totals = res.data.rowCount;
              this.infos = res.data.data;
              break;
          }
        }
        let postData = {}
        switch (this.activeName){
          case "first":
            this.pageSizes = 10;
            this.currentPages = 1;
            this.totals = 1;
            postData = {
              pageSize:this.pageSize,
              pageCurrent:this.currentPage,
              mainType:'0'
            };
            break;
          case "second":
            this.pageSize = 10;
            this.currentPage = 1;
            this.total = 1;
            postData = {
              pageSize:this.pageSizes,
              pageCurrent:this.currentPages,
              mainType:'1'
            };
            break;
        }

        let palyParam = {
          url: "/api/web/proStoreMaterial/selectMaterialBalanceSheetOfNormal",
          methods:'post',
          data: postData,
          success: suCb,
        }
        this.$https(palyParam)
      },
      handleClick(){
        this.dataInit();
      },
      //查看记录
      checkDetail(){
        alert(this.props)
      },
    }
  };
</script>

<style scoped>
  .tabs{
    width: 1100px;
    margin: 20px auto;
  }
  /* 搜索栏头部样式 */
  .component-searchHeader .search-header {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
  }

  .component-searchHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-searchHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    line-height: 45px;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    text-align: left;
    margin: 0 0 0 30px;
  }

  .component-searchHeader .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 30px;
  }

  .component-searchHeader .right button {
    padding: 0 15px;
    height: 30px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 12px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }

  .component-searchHeader .right button:hover {
    background-color: #f3f3f3;
  }

  /* 搜索框主体 */
  .component-search-box {
    width: 100%;
    height: 60px;
    box-sizing: border-box;
    background-color: #fff;
    border: 1px solid #e4e4e4;
    border-top: none;
    margin: 0 auto;
    text-align: left;
    padding-left: 30px;
    line-height: 60px;
  }

  .component-search-box .el-input__inner {
    height: 35px;
    display: inline-block;
  }

  /* 表头样式 */
  .component-listHeader .search-header {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(228, 228, 228, 1);
    background-color: rgba(255, 255, 255, 1);
    margin: 20px auto 0;
    border-bottom: none;
  }

  .component-listHeader .search-header .left-title {
    display: flex;
    justify-content: space-between;
    width: 100%;
    background-color: rgba(243, 243, 243, 1);
    height: 45px;
    box-sizing: border-box;
  }

  .component-listHeader .search-header .left-title .left-text {
    width: 20%;
    color: #666;
    font-family: "微软雅黑";
    font-weight: 400;
    font-size: 12px;
    line-height: 45px;
    text-align: left;
    margin: 0 0 0 30px;
  }

  .component-listHeader .search-header .right {
    width: 70%;
    display: flex;
    justify-content: flex-end;
    margin-right: 30px;
  }

  .component-listHeader .search-header .right button {
    padding: 0 15px;
    height: 30px;
    margin: 6px 5px;
    line-height: 30px;
    font-size: 14px;
    color: #666;
    background-color: #fff;
    border: 1px solid #ccc;
  }

  .component-listHeader .search-header .right button:hover {
    background-color: #f3f3f3;
  }

  .component-listHeader .search-header .right .right-select-margin {
    margin-top: 6px;
    margin-right: 8px;
  }

  /* 删除按钮 */
  .red {
    color: #48c9b0;
    font-size: 12px;
  }
</style>
